'use strict';

const moment = require('moment');

module.exports = {
  relativeTime: time => moment(new Date(time * 1000)).fromNow(),

  // 格式化时间
  formatTime: time => moment(time).format('YYYY-MM-DD hh:mm:ss'),

  pagination(page, size) {
    return {
      get page() {
        return (Number(page) || 1);
      },
      get size() {
        return (Number(size) || 10);
      },
      get limit() {
        return this.size;
      },
      get offset() {
        return (this.page - 1) * this.size;
      },
    };
  },
};

